IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Staff]') AND type in (N'U')) DROP TABLE [dbo].[Staff];
CREATE TABLE [dbo].[Staff](
    Id INT IDENTITY(1,1) ,
    staff_Id VARCHAR(50),
    staff_Name VARCHAR(50),
    staff_Contact VARCHAR(50),
    staff_Sex VARCHAR(2),
    Birthday DATETIME,
    Position VARCHAR(50),
    Scheduling_Id VARCHAR(50),
    staff_Status INT,
    Remarks VARCHAR(255),
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '员工表', 'SCHEMA', dbo, 'table', Staff, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Staff, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '员工工号', 'SCHEMA', dbo, 'table', Staff, 'column', staff_Id;
EXEC sp_addextendedproperty 'MS_Description', '姓名', 'SCHEMA', dbo, 'table', Staff, 'column', staff_Name;
EXEC sp_addextendedproperty 'MS_Description', '联系方式', 'SCHEMA', dbo, 'table', Staff, 'column', staff_Contact;
EXEC sp_addextendedproperty 'MS_Description', '性别', 'SCHEMA', dbo, 'table', Staff, 'column', staff_Sex;
EXEC sp_addextendedproperty 'MS_Description', '出生日期', 'SCHEMA', dbo, 'table', Staff, 'column', Birthday;
EXEC sp_addextendedproperty 'MS_Description', '职位', 'SCHEMA', dbo, 'table', Staff, 'column', Position;
EXEC sp_addextendedproperty 'MS_Description', '排班编号', 'SCHEMA', dbo, 'table', Staff, 'column', Scheduling_Id;
EXEC sp_addextendedproperty 'MS_Description', '状态', 'SCHEMA', dbo, 'table', Staff, 'column', staff_Status;
EXEC sp_addextendedproperty 'MS_Description', '备注', 'SCHEMA', dbo, 'table', Staff, 'column', Remarks;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Attendance]') AND type in (N'U')) DROP TABLE [dbo].[Attendance];
CREATE TABLE [dbo].[Attendance](
    Id INT IDENTITY(1,1) ,
    Attendance_Id VARCHAR(50),
    staff_Name VARCHAR(50),
    attendance_Date DATETIME,
    WorkHours DATETIME,
    ClosingTime DATETIME,
    attendance_Status INT,
    Remarks VARCHAR(255),
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '考勤表', 'SCHEMA', dbo, 'table', Attendance, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Attendance, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '考勤编码', 'SCHEMA', dbo, 'table', Attendance, 'column', Attendance_Id;
EXEC sp_addextendedproperty 'MS_Description', '员工工号', 'SCHEMA', dbo, 'table', Attendance, 'column', staff_Name;
EXEC sp_addextendedproperty 'MS_Description', '考勤日期', 'SCHEMA', dbo, 'table', Attendance, 'column', attendance_Date;
EXEC sp_addextendedproperty 'MS_Description', '上班时间', 'SCHEMA', dbo, 'table', Attendance, 'column', WorkHours;
EXEC sp_addextendedproperty 'MS_Description', '下班时间', 'SCHEMA', dbo, 'table', Attendance, 'column', ClosingTime;
EXEC sp_addextendedproperty 'MS_Description', '考勤状态', 'SCHEMA', dbo, 'table', Attendance, 'column', attendance_Status;
EXEC sp_addextendedproperty 'MS_Description', '备注', 'SCHEMA', dbo, 'table', Attendance, 'column', Remarks;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Marital]') AND type in (N'U')) DROP TABLE [dbo].[Marital];
CREATE TABLE [dbo].[Marital](
    Id INT IDENTITY(1,1) ,
    MaterialId VARCHAR(50),
    MaterialCode VARCHAR(50),
    MaterialName VARCHAR(50),
    MaterialType INT,
    MaterialVersions VARCHAR(50),
    measureUnitCode VARCHAR(50),
    measureUnitName VARCHAR(50),
    productModelId VARCHAR(50),
    productModelCode VARCHAR(50),
    regular VARCHAR(255),
    enableStatus INT,
    dataStatus INT,
    addTime DATETIME,
    editTime DATETIME,
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '物料表', 'SCHEMA', dbo, 'table', Marital, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Marital, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '物料ID', 'SCHEMA', dbo, 'table', Marital, 'column', MaterialId;
EXEC sp_addextendedproperty 'MS_Description', '物料号', 'SCHEMA', dbo, 'table', Marital, 'column', MaterialCode;
EXEC sp_addextendedproperty 'MS_Description', '物料名称', 'SCHEMA', dbo, 'table', Marital, 'column', MaterialName;
EXEC sp_addextendedproperty 'MS_Description', '物料类型', 'SCHEMA', dbo, 'table', Marital, 'column', MaterialType;
EXEC sp_addextendedproperty 'MS_Description', '物料版本', 'SCHEMA', dbo, 'table', Marital, 'column', MaterialVersions;
EXEC sp_addextendedproperty 'MS_Description', '计量单位编号', 'SCHEMA', dbo, 'table', Marital, 'column', measureUnitCode;
EXEC sp_addextendedproperty 'MS_Description', '计量单位名称', 'SCHEMA', dbo, 'table', Marital, 'column', measureUnitName;
EXEC sp_addextendedproperty 'MS_Description', '产品模型Id', 'SCHEMA', dbo, 'table', Marital, 'column', productModelId;
EXEC sp_addextendedproperty 'MS_Description', '产品模型编码', 'SCHEMA', dbo, 'table', Marital, 'column', productModelCode;
EXEC sp_addextendedproperty 'MS_Description', '条码正则表达式', 'SCHEMA', dbo, 'table', Marital, 'column', regular;
EXEC sp_addextendedproperty 'MS_Description', '物料状态', 'SCHEMA', dbo, 'table', Marital, 'column', enableStatus;
EXEC sp_addextendedproperty 'MS_Description', '数据删除状态', 'SCHEMA', dbo, 'table', Marital, 'column', dataStatus;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', Marital, 'column', addTime;
EXEC sp_addextendedproperty 'MS_Description', '修改时间', 'SCHEMA', dbo, 'table', Marital, 'column', editTime;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WorkOrder]') AND type in (N'U')) DROP TABLE [dbo].[WorkOrder];
CREATE TABLE [dbo].[WorkOrder](
    Id INT IDENTITY(1,1) ,
    orderId VARCHAR(50),
    orderCode VARCHAR(50),
    orderQty INT,
    materialId VARCHAR(50),
    materialCode VARCHAR(50),
    materialName VARCHAR(255),
    materialVersion VARCHAR(50),
    productBomId VARCHAR(50),
    productBomType VARCHAR(50),
    productBomVersion VARCHAR(50),
    lineId VARCHAR(50),
    lineCode VARCHAR(50),
    lineName VARCHAR(50),
    operationCode VARCHAR(50),
    assemblyMaterialId VARCHAR(50),
    assemblyMaterialCode VARCHAR(50),
    assemblyMaterialName VARCHAR(50),
    assemblyMaterialVersion VARCHAR(50),
    assemblyConsumption INT,
    assemblyUnitCode VARCHAR(50),
    retroactive VARCHAR(50),
    scheduleCode VARCHAR(50),
    standWorkHours DECIMAL(24,6),
    addTime DATETIME,
    editTime DATETIME,
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '工单', 'SCHEMA', dbo, 'table', WorkOrder, null, null;
EXEC sp_addextendedproperty 'MS_Description', '自增标识', 'SCHEMA', dbo, 'table', WorkOrder, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '工单ID', 'SCHEMA', dbo, 'table', WorkOrder, 'column', orderId;
EXEC sp_addextendedproperty 'MS_Description', '工单号', 'SCHEMA', dbo, 'table', WorkOrder, 'column', orderCode;
EXEC sp_addextendedproperty 'MS_Description', '工单数量', 'SCHEMA', dbo, 'table', WorkOrder, 'column', orderQty;
EXEC sp_addextendedproperty 'MS_Description', '产品ID', 'SCHEMA', dbo, 'table', WorkOrder, 'column', materialId;
EXEC sp_addextendedproperty 'MS_Description', '产品编号', 'SCHEMA', dbo, 'table', WorkOrder, 'column', materialCode;
EXEC sp_addextendedproperty 'MS_Description', '产品名称', 'SCHEMA', dbo, 'table', WorkOrder, 'column', materialName;
EXEC sp_addextendedproperty 'MS_Description', '产品版本', 'SCHEMA', dbo, 'table', WorkOrder, 'column', materialVersion;
EXEC sp_addextendedproperty 'MS_Description', 'BOMID', 'SCHEMA', dbo, 'table', WorkOrder, 'column', productBomId;
EXEC sp_addextendedproperty 'MS_Description', 'BOM类型', 'SCHEMA', dbo, 'table', WorkOrder, 'column', productBomType;
EXEC sp_addextendedproperty 'MS_Description', 'BOM版本', 'SCHEMA', dbo, 'table', WorkOrder, 'column', productBomVersion;
EXEC sp_addextendedproperty 'MS_Description', '产线ID', 'SCHEMA', dbo, 'table', WorkOrder, 'column', lineId;
EXEC sp_addextendedproperty 'MS_Description', '产线编码', 'SCHEMA', dbo, 'table', WorkOrder, 'column', lineCode;
EXEC sp_addextendedproperty 'MS_Description', '产线名称', 'SCHEMA', dbo, 'table', WorkOrder, 'column', lineName;
EXEC sp_addextendedproperty 'MS_Description', '工序编号', 'SCHEMA', dbo, 'table', WorkOrder, 'column', operationCode;
EXEC sp_addextendedproperty 'MS_Description', '组件物料ID', 'SCHEMA', dbo, 'table', WorkOrder, 'column', assemblyMaterialId;
EXEC sp_addextendedproperty 'MS_Description', '组件物料编号', 'SCHEMA', dbo, 'table', WorkOrder, 'column', assemblyMaterialCode;
EXEC sp_addextendedproperty 'MS_Description', '组件物料名称', 'SCHEMA', dbo, 'table', WorkOrder, 'column', assemblyMaterialName;
EXEC sp_addextendedproperty 'MS_Description', '组件物料版本', 'SCHEMA', dbo, 'table', WorkOrder, 'column', assemblyMaterialVersion;
EXEC sp_addextendedproperty 'MS_Description', '组件物料用量', 'SCHEMA', dbo, 'table', WorkOrder, 'column', assemblyConsumption;
EXEC sp_addextendedproperty 'MS_Description', '组件物料单位', 'SCHEMA', dbo, 'table', WorkOrder, 'column', assemblyUnitCode;
EXEC sp_addextendedproperty 'MS_Description', '追溯方式', 'SCHEMA', dbo, 'table', WorkOrder, 'column', retroactive;
EXEC sp_addextendedproperty 'MS_Description', '排程编号', 'SCHEMA', dbo, 'table', WorkOrder, 'column', scheduleCode;
EXEC sp_addextendedproperty 'MS_Description', '标准工时', 'SCHEMA', dbo, 'table', WorkOrder, 'column', standWorkHours;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', WorkOrder, 'column', addTime;
EXEC sp_addextendedproperty 'MS_Description', '修改时间', 'SCHEMA', dbo, 'table', WorkOrder, 'column', editTime;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Scheduling]') AND type in (N'U')) DROP TABLE [dbo].[Scheduling];
CREATE TABLE [dbo].[Scheduling](
    Id INT IDENTITY(1,1) ,
    Scheduling_Id VARCHAR(50),
    Team INT,
    Classes1 DATETIME,
    Classes2 DATETIME,
    Status INT,
    Remarks VARCHAR(255),
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '排班表', 'SCHEMA', dbo, 'table', Scheduling, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Scheduling, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '排班编号', 'SCHEMA', dbo, 'table', Scheduling, 'column', Scheduling_Id;
EXEC sp_addextendedproperty 'MS_Description', '班组', 'SCHEMA', dbo, 'table', Scheduling, 'column', Team;
EXEC sp_addextendedproperty 'MS_Description', '班次（上）', 'SCHEMA', dbo, 'table', Scheduling, 'column', Classes1;
EXEC sp_addextendedproperty 'MS_Description', '班次（下）', 'SCHEMA', dbo, 'table', Scheduling, 'column', Classes2;
EXEC sp_addextendedproperty 'MS_Description', '状态', 'SCHEMA', dbo, 'table', Scheduling, 'column', Status;
EXEC sp_addextendedproperty 'MS_Description', '备注', 'SCHEMA', dbo, 'table', Scheduling, 'column', Remarks;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RouteFiles]') AND type in (N'U')) DROP TABLE [dbo].[RouteFiles];
CREATE TABLE [dbo].[RouteFiles](
    Id INT IDENTITY(1,1) ,
    orderCode VARCHAR(50),
    routeCode VARCHAR(50),
    routeName VARCHAR(50),
    routeVersion VARCHAR(50),
    materialCode VARCHAR(50),
    materialName VARCHAR(50),
    materialVersion VARCHAR(50),
    operationCode VARCHAR(50),
    fileLoad VARCHAR(255),
    fileName VARCHAR(255),
    fileSource VARCHAR(255),
    fileType VARCHAR(50),
    itemSort INT,
    addTime DATETIME,
    editTime DATETIME,
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '工艺文件路径', 'SCHEMA', dbo, 'table', RouteFiles, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', RouteFiles, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '工单号', 'SCHEMA', dbo, 'table', RouteFiles, 'column', orderCode;
EXEC sp_addextendedproperty 'MS_Description', '工艺编号', 'SCHEMA', dbo, 'table', RouteFiles, 'column', routeCode;
EXEC sp_addextendedproperty 'MS_Description', '工艺名称', 'SCHEMA', dbo, 'table', RouteFiles, 'column', routeName;
EXEC sp_addextendedproperty 'MS_Description', '工艺版本', 'SCHEMA', dbo, 'table', RouteFiles, 'column', routeVersion;
EXEC sp_addextendedproperty 'MS_Description', '产品编号', 'SCHEMA', dbo, 'table', RouteFiles, 'column', materialCode;
EXEC sp_addextendedproperty 'MS_Description', '产品名称', 'SCHEMA', dbo, 'table', RouteFiles, 'column', materialName;
EXEC sp_addextendedproperty 'MS_Description', '产品版本', 'SCHEMA', dbo, 'table', RouteFiles, 'column', materialVersion;
EXEC sp_addextendedproperty 'MS_Description', '工序编号', 'SCHEMA', dbo, 'table', RouteFiles, 'column', operationCode;
EXEC sp_addextendedproperty 'MS_Description', '文件路径', 'SCHEMA', dbo, 'table', RouteFiles, 'column', fileLoad;
EXEC sp_addextendedproperty 'MS_Description', '文件名称', 'SCHEMA', dbo, 'table', RouteFiles, 'column', fileName;
EXEC sp_addextendedproperty 'MS_Description', '文件来源：XX系统，手工创建', 'SCHEMA', dbo, 'table', RouteFiles, 'column', fileSource;
EXEC sp_addextendedproperty 'MS_Description', '文件类型', 'SCHEMA', dbo, 'table', RouteFiles, 'column', fileType;
EXEC sp_addextendedproperty 'MS_Description', '工序顺序', 'SCHEMA', dbo, 'table', RouteFiles, 'column', itemSort;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', RouteFiles, 'column', addTime;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table', RouteFiles, 'column', editTime;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OrderList]') AND type in (N'U')) DROP TABLE [dbo].[OrderList];
CREATE TABLE [dbo].[OrderList](
    Id INT IDENTITY(1,1) 
    lineCode VARCHAR(50),
    lineName VARCHAR(50),
    materialCode VARCHAR(50),
    materialName VARCHAR(50),
    materialVersion VARCHAR(50),
    orderCode VARCHAR(50),
    orderQty INT,
    orderStatusCode VARCHAR(50),
    orderStatus INT,
    OrderType INT,
    productCode VARCHAR(50),
    productName VARCHAR(50),
    productVersion VARCHAR(50),
    scheduleCode VARCHAR(50),
    scheduleEditTime DATETIME,
    scheduleId VARCHAR(50),
    scheduleQty INT,
    scheduleStateCode VARCHAR(50),
    scheduleStatus INT,
    startTime DATETIME,
    endTime DATETIME,
    workshopCode VARCHAR(50),
    workshopName VARCHAR(50),
    field1 VARCHAR(255),
    field2 VARCHAR(255),
    field3 VARCHAR(255),
    field4 VARCHAR(255),
    field5 VARCHAR(255),
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '工程排程信息', 'SCHEMA', dbo, 'table', OrderList, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', OrderList, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '产线编号', 'SCHEMA', dbo, 'table', OrderList, 'column', lineCode;
EXEC sp_addextendedproperty 'MS_Description', '产线名称', 'SCHEMA', dbo, 'table', OrderList, 'column', lineName;
EXEC sp_addextendedproperty 'MS_Description', '物料编号', 'SCHEMA', dbo, 'table', OrderList, 'column', materialCode;
EXEC sp_addextendedproperty 'MS_Description', '物料名称', 'SCHEMA', dbo, 'table', OrderList, 'column', materialName;
EXEC sp_addextendedproperty 'MS_Description', '物料版本', 'SCHEMA', dbo, 'table', OrderList, 'column', materialVersion;
EXEC sp_addextendedproperty 'MS_Description', '工单号', 'SCHEMA', dbo, 'table', OrderList, 'column', orderCode;
EXEC sp_addextendedproperty 'MS_Description', '工单数量', 'SCHEMA', dbo, 'table', OrderList, 'column', orderQty;
EXEC sp_addextendedproperty 'MS_Description', '工单状态编码', 'SCHEMA', dbo, 'table', OrderList, 'column', orderStatusCode;
EXEC sp_addextendedproperty 'MS_Description', '工单状态', 'SCHEMA', dbo, 'table', OrderList, 'column', orderStatus;
EXEC sp_addextendedproperty 'MS_Description', '工单类型', 'SCHEMA', dbo, 'table', OrderList, 'column', OrderType;
EXEC sp_addextendedproperty 'MS_Description', '产品编码', 'SCHEMA', dbo, 'table', OrderList, 'column', productCode;
EXEC sp_addextendedproperty 'MS_Description', '产品名称', 'SCHEMA', dbo, 'table', OrderList, 'column', productName;
EXEC sp_addextendedproperty 'MS_Description', '产品版本', 'SCHEMA', dbo, 'table', OrderList, 'column', productVersion;
EXEC sp_addextendedproperty 'MS_Description', '排程编码', 'SCHEMA', dbo, 'table', OrderList, 'column', scheduleCode;
EXEC sp_addextendedproperty 'MS_Description', '排程计划结束时间', 'SCHEMA', dbo, 'table', OrderList, 'column', scheduleEditTime;
EXEC sp_addextendedproperty 'MS_Description', '排程主键', 'SCHEMA', dbo, 'table', OrderList, 'column', scheduleId;
EXEC sp_addextendedproperty 'MS_Description', '排程数量', 'SCHEMA', dbo, 'table', OrderList, 'column', scheduleQty;
EXEC sp_addextendedproperty 'MS_Description', '排程状态编码', 'SCHEMA', dbo, 'table', OrderList, 'column', scheduleStateCode;
EXEC sp_addextendedproperty 'MS_Description', '排程状态', 'SCHEMA', dbo, 'table', OrderList, 'column', scheduleStatus;
EXEC sp_addextendedproperty 'MS_Description', '计划开始时间', 'SCHEMA', dbo, 'table', OrderList, 'column', startTime;
EXEC sp_addextendedproperty 'MS_Description', '计划结束时间', 'SCHEMA', dbo, 'table', OrderList, 'column', endTime;
EXEC sp_addextendedproperty 'MS_Description', '车间编号', 'SCHEMA', dbo, 'table', OrderList, 'column', workshopCode;
EXEC sp_addextendedproperty 'MS_Description', '车间名称', 'SCHEMA', dbo, 'table', OrderList, 'column', workshopName;
EXEC sp_addextendedproperty 'MS_Description', '备用字段1', 'SCHEMA', dbo, 'table', OrderList, 'column', field1;
EXEC sp_addextendedproperty 'MS_Description', '备用字段2', 'SCHEMA', dbo, 'table', OrderList, 'column', field2;
EXEC sp_addextendedproperty 'MS_Description', '备用字段3', 'SCHEMA', dbo, 'table', OrderList, 'column', field3;
EXEC sp_addextendedproperty 'MS_Description', '备用字段4', 'SCHEMA', dbo, 'table', OrderList, 'column', field4;
EXEC sp_addextendedproperty 'MS_Description', '备用字段5', 'SCHEMA', dbo, 'table', OrderList, 'column', field5;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Routeparameters]') AND type in (N'U')) DROP TABLE [dbo].[Routeparameters];
CREATE TABLE [dbo].[Routeparameters](
    Id INT IDENTITY(1,1) ,
    materialCode VARCHAR(50),
    materialName VARCHAR(50),
    materialVersion VARCHAR(50),
    operationCode VARCHAR(50),
    paramCode VARCHAR(50),
    paramName VARCHAR(50),
    standardRange1 INT,
    standardRange2 INT,
    standardValue INT,
    targetValue INT,
    machineCode VARCHAR(50),
    field1 VARCHAR(255),
    field2 VARCHAR(255),
    field3 VARCHAR(255),
    field4 VARCHAR(255),
    addTime DATETIME,
    editTime DATETIME,
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '工艺参数', 'SCHEMA', dbo, 'table', Routeparameters, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Routeparameters, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '产品编号', 'SCHEMA', dbo, 'table', Routeparameters, 'column', materialCode;
EXEC sp_addextendedproperty 'MS_Description', '产品名称', 'SCHEMA', dbo, 'table', Routeparameters, 'column', materialName;
EXEC sp_addextendedproperty 'MS_Description', '产品版本', 'SCHEMA', dbo, 'table', Routeparameters, 'column', materialVersion;
EXEC sp_addextendedproperty 'MS_Description', '工序编码', 'SCHEMA', dbo, 'table', Routeparameters, 'column', operationCode;
EXEC sp_addextendedproperty 'MS_Description', '参数编码', 'SCHEMA', dbo, 'table', Routeparameters, 'column', paramCode;
EXEC sp_addextendedproperty 'MS_Description', '参数名称', 'SCHEMA', dbo, 'table', Routeparameters, 'column', paramName;
EXEC sp_addextendedproperty 'MS_Description', '下限值', 'SCHEMA', dbo, 'table', Routeparameters, 'column', standardRange1;
EXEC sp_addextendedproperty 'MS_Description', '上限值', 'SCHEMA', dbo, 'table', Routeparameters, 'column', standardRange2;
EXEC sp_addextendedproperty 'MS_Description', '标准值', 'SCHEMA', dbo, 'table', Routeparameters, 'column', standardValue;
EXEC sp_addextendedproperty 'MS_Description', '目标值', 'SCHEMA', dbo, 'table', Routeparameters, 'column', targetValue;
EXEC sp_addextendedproperty 'MS_Description', '设备编码', 'SCHEMA', dbo, 'table', Routeparameters, 'column', machineCode;
EXEC sp_addextendedproperty 'MS_Description', '备用字段1', 'SCHEMA', dbo, 'table', Routeparameters, 'column', field1;
EXEC sp_addextendedproperty 'MS_Description', '备用字段2', 'SCHEMA', dbo, 'table', Routeparameters, 'column', field2;
EXEC sp_addextendedproperty 'MS_Description', '备用字段3', 'SCHEMA', dbo, 'table', Routeparameters, 'column', field3;
EXEC sp_addextendedproperty 'MS_Description', '备用字段4', 'SCHEMA', dbo, 'table', Routeparameters, 'column', field4;
EXEC sp_addextendedproperty 'MS_Description', '创建时间', 'SCHEMA', dbo, 'table', Routeparameters, 'column', addTime;
EXEC sp_addextendedproperty 'MS_Description', '更新时间', 'SCHEMA', dbo, 'table', Routeparameters, 'column', editTime;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PassStation]') AND type in (N'U')) DROP TABLE [dbo].[PassStation];
CREATE TABLE [dbo].[PassStation](
    Id INT IDENTITY(1,1) ,
    serviceId VARCHAR(50),
    factoryCode VARCHAR(50),
    lineCode VARCHAR(50),
    snNumber VARCHAR(50),
    materialCode VARCHAR(50),
    workOrderNumber VARCHAR(50),
    scheduleNumber VARCHAR(50),
    trayNumber VARCHAR(50),
    reqType INT,
    startStationCode INT,
    stationCode VARCHAR(50),
    snBindState INT,
    barCode INT,
    state INT,
    userId VARCHAR(50),
    requestTime DATETIME,
    passBeginTime DATETIME,
    passEndTime DATETIME,
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '生产过站信息', 'SCHEMA', dbo, 'table', PassStation, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', PassStation, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', 'Service服务ID', 'SCHEMA', dbo, 'table', PassStation, 'column', serviceId;
EXEC sp_addextendedproperty 'MS_Description', '工厂代码', 'SCHEMA', dbo, 'table', PassStation, 'column', factoryCode;
EXEC sp_addextendedproperty 'MS_Description', '产线代码', 'SCHEMA', dbo, 'table', PassStation, 'column', lineCode;
EXEC sp_addextendedproperty 'MS_Description', '产品SN号', 'SCHEMA', dbo, 'table', PassStation, 'column', snNumber;
EXEC sp_addextendedproperty 'MS_Description', '产品物料编码', 'SCHEMA', dbo, 'table', PassStation, 'column', materialCode;
EXEC sp_addextendedproperty 'MS_Description', '工单编码', 'SCHEMA', dbo, 'table', PassStation, 'column', workOrderNumber;
EXEC sp_addextendedproperty 'MS_Description', '排程编码', 'SCHEMA', dbo, 'table', PassStation, 'column', scheduleNumber;
EXEC sp_addextendedproperty 'MS_Description', '托盘号', 'SCHEMA', dbo, 'table', PassStation, 'column', trayNumber;
EXEC sp_addextendedproperty 'MS_Description', '类型', 'SCHEMA', dbo, 'table', PassStation, 'column', reqType;
EXEC sp_addextendedproperty 'MS_Description', '是否首工位进站', 'SCHEMA', dbo, 'table', PassStation, 'column', startStationCode;
EXEC sp_addextendedproperty 'MS_Description', '工位代码', 'SCHEMA', dbo, 'table', PassStation, 'column', stationCode;
EXEC sp_addextendedproperty 'MS_Description', 'SN绑定状态', 'SCHEMA', dbo, 'table', PassStation, 'column', snBindState;
EXEC sp_addextendedproperty 'MS_Description', '打印条码', 'SCHEMA', dbo, 'table', PassStation, 'column', barCode;
EXEC sp_addextendedproperty 'MS_Description', '状态（pass出站填写）', 'SCHEMA', dbo, 'table', PassStation, 'column', state;
EXEC sp_addextendedproperty 'MS_Description', '用户工号', 'SCHEMA', dbo, 'table', PassStation, 'column', userId;
EXEC sp_addextendedproperty 'MS_Description', '发送过站请求的时间', 'SCHEMA', dbo, 'table', PassStation, 'column', requestTime;
EXEC sp_addextendedproperty 'MS_Description', '入站时间', 'SCHEMA', dbo, 'table', PassStation, 'column', passBeginTime;
EXEC sp_addextendedproperty 'MS_Description', '出站时间', 'SCHEMA', dbo, 'table', PassStation, 'column', passEndTime;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Warning]') AND type in (N'U')) DROP TABLE [dbo].[Warning];
CREATE TABLE [dbo].[Warning](
    Id INT IDENTITY(1,1) ,
    unusualAlarmCode VARCHAR(50),
    message VARCHAR(255),
    workShopCode VARCHAR(50),
    stationCode VARCHAR(50),
    lineCode VARCHAR(50),
    machineCode VARCHAR(50),
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '预警信息', 'SCHEMA', dbo, 'table', Warning, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Warning, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '异常预警时间编码', 'SCHEMA', dbo, 'table', Warning, 'column', unusualAlarmCode;
EXEC sp_addextendedproperty 'MS_Description', '异常信息（报警文本+SN+工位+产线+设备名称）', 'SCHEMA', dbo, 'table', Warning, 'column', message;
EXEC sp_addextendedproperty 'MS_Description', '车间编码', 'SCHEMA', dbo, 'table', Warning, 'column', workShopCode;
EXEC sp_addextendedproperty 'MS_Description', '工位编码', 'SCHEMA', dbo, 'table', Warning, 'column', stationCode;
EXEC sp_addextendedproperty 'MS_Description', '产线编码', 'SCHEMA', dbo, 'table', Warning, 'column', lineCode;
EXEC sp_addextendedproperty 'MS_Description', '设备编码', 'SCHEMA', dbo, 'table', Warning, 'column', machineCode;

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Alarmlog]') AND type in (N'U')) DROP TABLE [dbo].[Alarmlog];
CREATE TABLE [dbo].[Alarmlog](
    Id INT IDENTITY(1,1) ,
    alarmId VARCHAR(50),
    alarmMesg VARCHAR(255),
    alarmState INT,
    startTime DATETIME,
    endTime DATETIME,
    stationCode VARCHAR(50),
    lineCode VARCHAR(50),
    machineCode VARCHAR(50),
    createTime DATETIME,
    createBy VARCHAR(50),
    updateTime DATETIME,
    updateBy VARCHAR(50),
    factoryCode VARCHAR(50),
    PRIMARY KEY (Id)
);

EXEC sp_addextendedproperty 'MS_Description', '报警信息', 'SCHEMA', dbo, 'table', Alarmlog, null, null;
EXEC sp_addextendedproperty 'MS_Description', '编号', 'SCHEMA', dbo, 'table', Alarmlog, 'column', Id;
EXEC sp_addextendedproperty 'MS_Description', '报警ID', 'SCHEMA', dbo, 'table', Alarmlog, 'column', alarmId;
EXEC sp_addextendedproperty 'MS_Description', '报警信息', 'SCHEMA', dbo, 'table', Alarmlog, 'column', alarmMesg;
EXEC sp_addextendedproperty 'MS_Description', '报警状态（0:创建，1:关闭）', 'SCHEMA', dbo, 'table', Alarmlog, 'column', alarmState;
EXEC sp_addextendedproperty 'MS_Description', '报警开始时间', 'SCHEMA', dbo, 'table', Alarmlog, 'column', startTime;
EXEC sp_addextendedproperty 'MS_Description', '报警结束时间', 'SCHEMA', dbo, 'table', Alarmlog, 'column', endTime;
EXEC sp_addextendedproperty 'MS_Description', '工位编码', 'SCHEMA', dbo, 'table', Alarmlog, 'column', stationCode;
EXEC sp_addextendedproperty 'MS_Description', '产线编码', 'SCHEMA', dbo, 'table', Alarmlog, 'column', lineCode;
EXEC sp_addextendedproperty 'MS_Description', '设备编码', 'SCHEMA', dbo, 'table', Alarmlog, 'column', machineCode;
EXEC sp_addextendedproperty 'MS_Description', '报警创建时间', 'SCHEMA', dbo, 'table', Alarmlog, 'column', createTime;
EXEC sp_addextendedproperty 'MS_Description', '报警创建用户', 'SCHEMA', dbo, 'table', Alarmlog, 'column', createBy;
EXEC sp_addextendedproperty 'MS_Description', '报警更新时间', 'SCHEMA', dbo, 'table', Alarmlog, 'column', updateTime;
EXEC sp_addextendedproperty 'MS_Description', '报警更新用户', 'SCHEMA', dbo, 'table', Alarmlog, 'column', updateBy;
EXEC sp_addextendedproperty 'MS_Description', '工厂编码', 'SCHEMA', dbo, 'table', Alarmlog, 'column', factoryCode;

